package com.apartment.dao;

import com.apartment.data.entity.Apartment;
import com.apartment.data.entity.Collect;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;

import java.util.List;
import java.util.Map;

/**
 * Author : xuzhiyong
 * Date : 2022/6/5 22:22
 */
public interface ServeDao extends JpaRepository<Collect,Integer> {

    @Query(value = "select c.id,c.user_id,c.apartment_id from Collect c where c.user_id = ?1",nativeQuery = true)
    List<Collect> finCollectByUserId(Integer id);

    @Query(value = "select a.id,a.landlord_id,a.address,a.apartment_type,a.apartment_statu,a.content,a.picture,a.price,a.username from Apartment a where a.address like %?1%",nativeQuery = true)
    List<Map<String, Object>> findApartmentByLike(String keyword);
}
